package com.xc.controller;

import com.xc.dto.ResultDTO;
import com.xc.entity.CourseEntity;
import com.xc.entity.PermissionEntity;
import com.xc.service.CourseService;
import com.xc.service.PermissionService;
import com.xc.util.Tool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//restful 增加post，修改put，删除delete，查询get
@RestController
@RequestMapping("/xc/course")
@Api(tags = "课程功能管理")
public class CourseController {
    @Autowired
    private CourseService courseService;

    @ApiOperation(value = "课程功能增加",notes = "课程功能增加接口的说明")
    @PostMapping()
    public ResultDTO add(@RequestBody CourseEntity courseEntity) {
        return courseService.add(courseEntity);
    }

    @ApiOperation("课程功能修改")
    @PutMapping()
    public ResultDTO update(@RequestBody CourseEntity courseEntity) {
        return courseService.update(courseEntity);
    }

    @ApiOperation("根据id进行删除课程功能数据")
    @DeleteMapping("/{id}")
    public ResultDTO delete(CourseEntity courseEntity) {
        return courseService.delete(courseEntity);
    }

    @ApiOperation("查询所有课程功能数据")
    @GetMapping()
    public ResultDTO findAll(CourseEntity courseEntity) {
        courseEntity.setPage(Tool.strToPage(courseEntity.getPage() + ""));
        courseEntity.setLimit(Tool.strToLimit(courseEntity.getLimit() + ""));
        return courseService.findAll(courseEntity);
    }

    @ApiOperation("根据id查询课程功能")
    @GetMapping("/{id}")
    public ResultDTO findById(CourseEntity courseEntity) {
        return courseService.findById(courseEntity);
    }

    @ApiOperation("查询课程功能总条数")
    @GetMapping("/count")
    public ResultDTO count(CourseEntity courseEntity) {
        return courseService.count(courseEntity);
    }
}
